<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>timerManager</title>
</head>

<body>
    <div class="test">打开浏览器控制台查看结果</div>
    <script>
        class TimerManager {
            constructor() {
                this.timerList = [];
                this.params = [];
                this.isRunTimer = false;
            }
            static makeTimerManage(element) {
                if (
                    !element.makeTimerManage ||
                    element.TimerManager.constructor !== TimerManager
                ) {
                    element.TimerManager = new TimerManager();
                }
            }
            add(timer, args) {
                this.timerList.push(timer);
                this.params.push(args);
                this.runTimer();
            }
            runTimer() {
                if (!this.isRunTimer) {
                    const timer = this.timerList.shift(),
                        args = this.params.shift();
                    if (timer && args) {
                        this.isRunTimer = true;
                        timer(...args);
                    }
                }
            }
            next() {
                this.isRunTimer = false;
                this.runTimer();
            }
        }
        const slideUp = () => {
            // ....
            console.log(document.querySelector('.test').TimerManager);
        };
        const animation = (element, ...args) => {
            TimerManager.makeTimerManage(element);
            element.TimerManager.add(slideUp, args);
        };
        animation(document.querySelector('.test'), '1'); // TimerManager
    </script>
</body>

</html>